
import time
import random
import threading

product_list = []
num = 0


def product_num(num):
    while True:
        num += 1
        product_time = random.randint(1,3)
        time.sleep(product_time)
        print('product num:',num)
        product_list.append(num)


def consume_num(num):
    while True:
        consum_time = random.randint(3, 5)
        time.sleep(consum_time)
        num = product_list.pop()
        print('consume product',num)



if __name__ == "__main__":
    t1 = threading.Thread(target=product_num,args=(num,))
    t2 = threading.Thread(target=consume_num,args=(num,))
    t1.start()
    t2.start()
    t1.join()
    t2.join()